package com.example.cloud.config;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @date 2024/5/6
 */
@Configuration
public class RestTemplateConfig {

    @Bean
    @LoadBalanced // 此注解的作用是让RestTemplate具有客户端负载均衡的功能，如果不加此注解会报错, unKnowHostName
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder.build();
    }
}
